package com.android1.amarena2d.test;

import com.android1.amarena2d.actions.base.Action;
import com.android1.amarena2d.actions.base.Sequence;
import com.android1.amarena2d.actions.instant.Active;
import com.android1.amarena2d.actions.movement.MoveIn;
import com.android1.amarena2d.actions.transition.SlideLeftTransition;
import com.android1.amarena2d.actions.transition.SlideRightTransition;
import com.android1.amarena2d.nodes.Scene;
import com.android1.amarena2d.nodes.SimpleLabel;
import com.android1.amarena2d.nodes.sprites.Sprite;
import com.android1.amarena2d.texture.Textures;

public class TransitionExampleScene extends Scene {

    int selected = 0;
//    ArrayList<Item> transitions = new ArrayList<Item>(20);

    boolean first = true;
    SimpleLabel label;
    Sprite sprite1;
    Sprite sprite2;
    SlideLeftTransition transition1 = new SlideLeftTransition(1);
    SlideRightTransition transition2 = new SlideRightTransition(1);
//    Transition transition = new FadeTransition(5);

    Action a = Sequence.$(Active.$(true), MoveIn.$fromRight(1));

    public TransitionExampleScene() {

        touch().makeTouchable(this);

        sprite1 = new Sprite(Textures.$("assets/donut.png").get(), 100, 10);
        sprite2 = new Sprite(Textures.$("assets/cupcake.png").get(), 100, 40);

        add(sprite1);
        add(sprite2);

    }

    @Override
    protected void onEnterFinished() {
        sprite2.setActive(false);
    }

    @Override
    public boolean onTouchDown(float x, float y, int pointer, boolean isHit) {

//        sprite1.action().run(a);

        if (first) {
            transition1.play(sprite2, sprite1);
            first = false;
        } else {
            transition2.play(sprite1, sprite2);
            first = true;
        }

        return true;
    }

//    private void next() {
//        Emitter emitter = this.emitter.get(selected).emitter;
//        emitter.stop();
//        emitter.reset();
//        selected++;
//        if (selected == this.emitter.size()) {
//            selected = 0;
//        }
//        label.setText(this.emitter.get(selected).name);
//        this.emitter.get(selected).emitter.play();
//
//    }
//
//    private final class Item {
//        public String name;
//        public Transition emitter;
//
//        private Item(String name, Emitter emitter) {
//            this.name = name;
//            this.emitter = emitter;
//        }
//    }
}